/**
 * Company : Thai Informatic System Co., Ltd.
 * Created By : Dr.Tree
 * Created On : Jul 14, 2012  7:14:24 PM 
 * e-Mail : chatree@tis.co.th
 * Mobile Phone : (+66) 087-921-5115
 * Package Name : jpa.service.promis.construction
 * File Name : VwSyncContractsHRiseServices.java
 * TODO
 */
package jpa.service.promis.construction;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;

import promis.utility.CommonService;

import jpa.entitys.promis.construction.VwSyncContractsHRise;
import jpa.service.common.JPAService;

/**
 * @author chatree
 *
 */
public class VwSyncContractsHRiseServices extends JPAService {

	/**
	 * @param em
	 */
	public VwSyncContractsHRiseServices(EntityManager em) {
		super(em);
		// TODO Auto-generated constructor stub
	}

	public VwSyncContractsHRise findById(String id) throws Exception {		
		
		return super.ConvertToYoureObject(super.find(id, "VwSyncContractsHRise.findById"));				
	}
	
	public List<VwSyncContractsHRise> findAll() throws Exception {
		return super.ConvertToYoureObject(super.findAll("VwSyncContractsHRise.findAll"));
	}
	
	public List<VwSyncContractsHRise> findByDocumentNo(String company, String project ,String documentNo, String status, String syncIsstaging) throws Exception {
		Map<String,Object> mapWhereValue = new HashMap<String, Object>();				
		mapWhereValue.put("company", company);
		mapWhereValue.put("project", project);
		mapWhereValue.put("documentNo", documentNo);
		mapWhereValue.put("status", status);
		
		if(!CommonService.IsNull(syncIsstaging))
		{
			mapWhereValue.put("syncIsstaging", syncIsstaging);
			return super.ConvertToYoureObject(super.find("VwSyncContractsHRise.findByDocumentNo1", mapWhereValue));
			
		}else
			return super.ConvertToYoureObject(super.find("VwSyncContractsHRise.findByDocumentNo", mapWhereValue));
	}
	
	public List<VwSyncContractsHRise> findByDocumentNo(String company, String documentNo, String status, String syncIsstaging) throws Exception {
		Map<String,Object> mapWhereValue = new HashMap<String, Object>();				
		mapWhereValue.put("company", company);
		mapWhereValue.put("documentNo", documentNo);
		mapWhereValue.put("status", status);
		
		if(!CommonService.IsNull(syncIsstaging))
		{
			mapWhereValue.put("syncIsstaging", syncIsstaging);
			return super.ConvertToYoureObject(super.find("VwSyncContractsHRise.findByDocumentNo3", mapWhereValue));
			
		}else
			return super.ConvertToYoureObject(super.find("VwSyncContractsHRise.findByDocumentNo2", mapWhereValue));
	}
	
}
